package ch.wanandroid.lib.banner;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;

import ch.wanandroid.comr.lib.R;

public class SimpleGuideBanner extends BaseIndicatorBanner<Integer,SimpleGuideBanner> {
    private Context mContext;

    public SimpleGuideBanner(Context context) {
        this(context, null, 0);
    }

    public SimpleGuideBanner(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public SimpleGuideBanner(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        mContext=context;
    }
    @Override
    public View onCreateItemView(int position) {
        View view=LayoutInflater.from(mContext).inflate(R.layout.adapter_simple_guide,null);
        TextView mTextView=view.findViewById(R.id.tv_jump);
        mTextView.setVisibility(position==mDatas.size()-1?VISIBLE:GONE);
        ImageView mImage=view.findViewById(R.id.image_iv);
        int dataResource=mDatas.get(position);
        Glide.with(mContext)
                .load(dataResource)
                .into(mImage);
        mTextView.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mGuideClickListen!=null){
                    mGuideClickListen.onClick();
                }
            }
        });
        return view;
    }

    @Override
    public void onTitleSlect(TextView tv, int position) {

    }

    private GuideClickListen mGuideClickListen;
    public interface GuideClickListen{
        void onClick();
    }
    public SimpleGuideBanner setGuideClickListen(GuideClickListen mGuideClickListen){
        this.mGuideClickListen=mGuideClickListen;
        return this;
    }

}
